package com.cn.aware;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

/**
 * 可以解析占位符
 */
@Component
public class SelfEmbeddedValueResolverAware implements EmbeddedValueResolverAware, InitializingBean {

	StringValueResolver resolver;

	@Override
	public void setEmbeddedValueResolver(StringValueResolver resolver) {
		this.resolver = resolver;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		String value = resolver.resolveStringValue("测试-${USERNAME}");
		System.out.println("EmbeddedValueResolver Resolve:"+value);
	}
}
